#pragma once

#include "BaseSolver.h"
#include "SolveEqu.h"
namespace Solver
{
class DoglegSolver : public BaseSolver
{
public:
    DoglegSolver();
    ~DoglegSolver();

private:
    bool init();
    void solveByIter();

    void calcG();

    void calcAlpha();

    void calcBeta();

    void calcJacobi(const VectorXd_t &x);

    bool solveVDX();

    void modifyDx();

    inline value_t calcError(const VectorXd_t &x);

private:
    value_t alpha_, beta_, thres_, bestError_, currentError_;
    VectorXd_t bestX_, x_, y_, g_, vDx_;
    MatrixXd_t jacobi_;
    SolveEqu lineSolver_;
};
}